package com.zds.support.api.retrofit.converter.gson

import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import java.lang.reflect.Type
import java.text.SimpleDateFormat
import java.util.*

/**
 *
 * @Description: DateDeserializer
 * @author zc
 * @version V1.0
 */
class DateDeserializer : JsonDeserializer<Date> {
    val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): Date {
        try {
            if (json != null) {
                return df.parse(json.getAsString());
            }
        } catch (e: Exception) {

        }
        return Date()
    }
}